/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Emanoel
 */
public class TrataOptdigits {

    public static void main(String[] args) {
        BufferedReader br = null;        
        BufferedWriter bw = null;
        int ordemLinha = 0;
        try {
            br = new BufferedReader(new FileReader("src/rede/optdigits_tratado.tra"));
            bw = new BufferedWriter(new FileWriter("src/rede/optdigits_tratado2.tra"));
            String linha = br.readLine();
            String linhaTratada;
            String[] valores = null;
            while (linha != null) {
                linhaTratada = "";
                valores = linha.split(",");                
                for (int i = 0; i < valores.length; i++) {
                    linhaTratada += Double.parseDouble(valores[i]) + ",";
                }
                linhaTratada = linhaTratada.substring(0, linhaTratada.length() - 3);
                bw.write(linhaTratada + "\n");
                linha = br.readLine();
            }
        } catch (IOException ex) {
            Logger.getLogger(ArquivoUtil.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            try {
                br.close();
                bw.close();
            } catch (IOException ex) {
                Logger.getLogger(ArquivoUtil.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}
